var app = getApp();
Component({
    properties: {
        isshow : Number,
        params : Object,
        clicktype : Number,
        url : String,
        isneed : Number,
        zfid : Number,
    },
    data: {
        showuserbtn: false,
    },
    options : {
        addGlobalClass : true,
    },
    ready:function(){
        if(this.data.isshow*1 == 1){
            this.hideauth();
        }
    },
    methods: {
        updateUserInfo : function(e){
            var self = this;
            app.com.getUserInfo(function(res){
                self.setData({
                    showuserbtn:false,
                });
                if(self.data.url && self.data.clicktype*1 == 1){
                    var weburl = encodeURIComponent( self.data.url );
                    wx.navigateTo({
                        url: '/zofui_sales/pages/webview/webview?url='+weburl,
                    });
                }
                var zfid = self.data.zfid > 0 ? self.data.zfid : 0;
                app.com.http('user_v1','POST',{zfid:zfid},0,false,'','',function(res){});

                var user = {
                    isend : 1,
                    nickname : res.wxInfo.nickName,
                    headimg : res.wxInfo.avatarUrl,
                }
                self.triggerEvent('authed',user);
            },false,e.detail);
        },
        hideauth(){
            this.setData({
                showuserbtn : !this.data.showuserbtn,
            });
        },
        showauth(){
            this.setData({
                showuserbtn : true,
            });
        },
        hideme(){
            this.setData({
                showuserbtn : false,
            });
        }
    }
});